﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.Views.CUiExportToRTRWindow
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Threading;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.ExportToRTR.Views;

public class CUiExportToRTRWindow : TxWindow, IComponentConnector
{
  private Dispatcher _currentDispatcher;
  private CUiExportToRTRProgressHandler _progressHandler;
  internal CUiExportToRTRWindow ExportWindow;
  internal Label ProgressLabel;
  internal ProgressBar ExportWinProgressBar;
  internal CUiExportToRTROutputView outputGroup;
  internal CUiExportToRTRContentTreeView contentGroup;
  internal TextBox Messeges;
  internal Button exportBtn;
  internal Button closeBtn;
  private bool _contentLoaded;

  public CUiExportToRTRWindow(CUiExportToRTRWindowViewModel vm)
  {
    this.InitializeComponent();
    vm.CloseAction = new Action(((Window) this).Close);
    ((FrameworkElement) this).DataContext = (object) vm;
    this.ExportWinProgressBar.IsIndeterminate = false;
    this.ExportWinProgressBar.Minimum = 0.0;
    this.ExportWinProgressBar.Maximum = 200.0;
    this._currentDispatcher = ((DispatcherObject) this).Dispatcher;
    this._progressHandler = new CUiExportToRTRProgressHandler(this.ExportWinProgressBar.Maximum, new Action<double>(this.SetProgressValue));
    vm.ProgressDataHandler = this._progressHandler;
    vm.CurrentDispatcher = this._currentDispatcher;
    vm.Init();
  }

  protected virtual void OnRender(DrawingContext drawingContext)
  {
    // ISSUE: explicit non-virtual call
    __nonvirtual (((UIElement) this).OnRender(drawingContext));
  }

  private void ExportWindow_Loaded(object sender, RoutedEventArgs e)
  {
    ((Window) this).SizeToContent = SizeToContent.Height;
  }

  private void ExportWindow_Closed(object sender, EventArgs e)
  {
    TxWindowSettings.StoreWindowValue((TxWindow) this, "LOD_VALUE", (object) CApExportToRTRExportManager.LOD_VALUE);
  }

  protected virtual void OnClosing(CancelEventArgs e)
  {
    if (((FrameworkElement) this).DataContext is CUiExportToRTRWindowViewModel dataContext)
      dataContext.OutputVm.PersistConnectionSettings();
    base.OnClosing(e);
  }

  public void UpdateFromRtr()
  {
    if (!(((FrameworkElement) this).DataContext is CUiExportToRTRWindowViewModel dataContext))
      return;
    dataContext.Initialize();
  }

  public void SetProgressValue(double progressValue)
  {
    this.ExportWinProgressBar.Value = progressValue;
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/exporttortr/window/views/cuiexporttortrwindow.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  internal Delegate _CreateDelegate(Type delegateType, string handler)
  {
    return Delegate.CreateDelegate(delegateType, (object) this, handler);
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this.ExportWindow = (CUiExportToRTRWindow) target;
        ((FrameworkElement) this.ExportWindow).Loaded += new RoutedEventHandler(this.ExportWindow_Loaded);
        ((Window) this.ExportWindow).Closed += new EventHandler(this.ExportWindow_Closed);
        break;
      case 2:
        this.ProgressLabel = (Label) target;
        break;
      case 3:
        this.ExportWinProgressBar = (ProgressBar) target;
        break;
      case 4:
        this.outputGroup = (CUiExportToRTROutputView) target;
        break;
      case 5:
        this.contentGroup = (CUiExportToRTRContentTreeView) target;
        break;
      case 6:
        this.Messeges = (TextBox) target;
        break;
      case 7:
        this.exportBtn = (Button) target;
        break;
      case 8:
        this.closeBtn = (Button) target;
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
